//
//  USB_cocoa.h
//  amBXCocoa
//
//  Created by João Pedro Estilita Antunes on 23/11/09.
//  Copyright 2009 João Estilita. All rights reserved.
//  j.estilita@gmail.com
//

#import <Cocoa/Cocoa.h>

#include <CoreFoundation/CoreFoundation.h>

#include <IOKit/IOKitLib.h>
#include <IOKit/IOMessage.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/usb/IOUSBLib.h>

#define kMyVendorID
#define kMyProductID

@interface USB_cocoa : NSObject {
	
	CFMutableDictionaryRef 	matchingDict;
    CFRunLoopSourceRef		runLoopSource;
    CFNumberRef				numberRef;
	//    kern_return_t			kr;
    long					usbVendor;
    long					usbProduct;
    sig_t					oldHandler;
	
	//	kern_return_t		kr;
	//    io_service_t		usbDevice;
	//    IOCFPlugInInterface	**plugInInterface;
	//    SInt32				score;
	//    HRESULT 			res;
	//	
	//	io_name_t		deviceName;
	//	CFStringRef		deviceNameAsCFString;	
	//	UInt32			locationID;
	
	io_object_t				notification_private;
    IOUSBDeviceInterface	**deviceInterface_private;
	IOUSBInterfaceInterface	**interfaceInterface_private;
	CFStringRef				deviceName_private;
    UInt32					locationID_private;
	
	IONotificationPortRef	gNotifyPort;
	io_iterator_t			gAddedIter;
	CFRunLoopRef			gRunLoop;
	
	io_service_t		usbDevice;
	
	IOUSBInterfaceInterface     **interface;
	
	int red_global;
	int green_global;
	int blue_global;
	
	NSThread *thread;
	
}

@property(readwrite) int red_global, green_global, blue_global;

- (void)OpenDevice;
- (int)UpdateRed;
- (int)UpdateGreen;
- (int)UpdateBlue;
- (void)CloseDevice;
- (void)sendValuesToSelectedLight:(int)speakerLeft:(int)washerLeft:(int)washerCenter:(int)washerRight:(int)speakerRight;
- (void)sendValuesToSpeakerLeft:(int)red:(int)green:(int)blue;
- (void)sendValuesToSpeakerRight:(int)red:(int)green:(int)blue;
- (void)sendValuesToWasherLeft:(int)red:(int)green:(int)blue;
- (void)sendValuesToWasherCenter:(int)red:(int)green:(int)blue;
- (void)sendValuesToWasherRight:(int)red:(int)green:(int)blue;
- (void)sendTimedSequence:(char)timeHighByte:(char)timeLowByte;
- (void)sendFanSpeed:(int)leftSpeed:(int)rightSpeed;
- (void)rumblePadSpeed:(int)rumbleLeftSpeed:(int)rumbleRightSpeed;



@end
